<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        height: 200px;
        border: 1px solid black;
      }
      /* 根据flex实现 */
      .flex {
        display: flex;
        /* 主轴对齐方式 */
        justify-content: center;
        /* 交叉轴对齐方式 */
        align-items: center;
      }
      .b1 {
        height: 100px;
        width: 100px;
        background-color: brown;
      }
      /* 根据定位实现 */
      .position {
        position: relative;
      }
      .b2 {
        height: 100px;
        width: 100px;
        background-color: brown;
        position: absolute;
        left: 50%;
        top: 50%;
        margin-left: -50px;
        margin-top: -50px;
      }
    </style>
  </head>
  <body>
    <div id="box" class="flex">
      <div class="b1"></div>
    </div>
    <div id="box" class="position">
      <div class="b2"></div>
    </div>
    <div id="box"></div>
    <div id="box"></div>
    <div id="box"></div>
    <div id="box"></div>
  </body>
</html>
